﻿using System;
using System.Windows.Forms;
using Gui.Functies.Agenda;
using Gui.Functies.Filesharing;
using Gui.Functies.Home;
using Gui.Functies.Login;

namespace Gui
{
    public partial class Interface : Form
    {
        private int projectnummer;
        private int userId;
        private int[] id;
        private string[] title;
        private string[] description;
        int projectAmount;
        
        public Interface()
        {
            Login loadingDone = new Login();
        }
        //Constructor
        public Interface(int project, int[] ids, string[] titles, string[] descriptions, int projectAantal, int userID)
        {
            projectnummer = project;
            id = ids;
            title = titles;
            description = descriptions;
            userId = userID;
            projectAmount = projectAantal;
            InitializeComponent();
            panelMain.Controls.Add(new Home(projectnummer, userId));
        }

        //Home button
        private void buttonHome_Click(object sender, EventArgs e)
        {
            panelMain.Controls.Clear();
            loadFunction(4);
        }

        //Chatclient starten
        private void btnChat_Click(object sender, EventArgs e)
        {
            Functies.Chatclient.Chat chat = new Functies.Chatclient.Chat();
            chat.Show();
        }
        //Agenda scherm starten
        private void btnAgenda_Click(object sender, EventArgs e)
        {     
            loadFunction(1);
        }
        //Takenlijst starten
        private void btnTakenlijst_Click(object sender, EventArgs e)
        {
            loadFunction(2);
        }
        //Fileshare starten
        private void btnFileshare_Click(object sender, EventArgs e)
        {
            loadFunction(3);
        }
        //Alle functies die hierboven worden geladen door de buttons staan in deze methode.
        private void loadFunction(int choice)
        {
            int panel = choice;

            switch(panel)
            {
                case 1:                    
                    //zie functies -> agenda + agendapunten
                    panelMain.Controls.Clear();
                    panelMain.Controls.Add(new Agenda(projectnummer));
                    break;
                case 2:
                    //zie functies -> takenlijst
                    panelMain.Controls.Clear();
                    panelMain.Controls.Add(new Functies.Takenlijst.Takenlijst(projectnummer));
                    break;
                case 3:
                    //zie functies -> fileshare
                    panelMain.Controls.Clear();
                    panelMain.Controls.Add(new Fileshare(projectnummer));
                    break; 
                case 4:
                    //zie functies -> home
                    panelMain.Controls.Clear();
                    panelMain.Controls.Add(new Home(projectnummer, userId));
                    break;
            }
        }

        //Sluit de applicatie af.
        private void exitStrip_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        
        //Stuurt je terug naar de de overview van projecten.
        private void overviewStrip_Click(object sender, EventArgs e)
        {
            Gui.Functies.Project_keuzemenu.Projectkeuzemenu overview = new Functies.Project_keuzemenu.Projectkeuzemenu(id, title, description, projectAmount, userId);
            this.Hide();
            overview.Show();
        }

        //Logt je uit en stuurt je terug naar het logins scherm.
        private void logoutStrip_Click(object sender, EventArgs e)
        {
            Application.Restart();
        }   
    }
}